#include"FuncApp.hpp"
#include<memory>
#include"RpcClient.hpp"
#include"FuncService.hpp"
#include"FuncHandler.hpp"
#include"SceneSim.hpp"


namespace SC_SUN
{


FuncApp::FuncApp(const std::string& router, uint16_t port, const std::string& mapServerIp, uint16_t mapServerPort)
    :mRouter(router)
    ,mPort(port)
    ,mRpcIp(mapServerIp)
    ,mRpcPort(mapServerPort)
{
    //创建rpc对象
    mRpcClient = std::make_shared<RpcClient>(mRpcIp, mRpcPort, [this](bool status){});

    //创建服务对象
    mFuncService = std::make_shared<FuncService>(mRouter, mPort);

    //创建详细处理对象
    mFuncHandler = std::make_shared<FuncHandler>(*mFuncService, *this);

    //创建场景信息对象
    mSceneSim = std::make_shared<SceneSim>(*this);
}

FuncApp::~FuncApp()
{

}

bool FuncApp::Start()
{
    mRpcClient->Start();
    mFuncService->Start();
    mFuncHandler->Start();
    mSceneSim->Start();

    return true;
}

void FuncApp::Stop()
{
    mRpcClient->Stop();
    mFuncService->Stop();
    mFuncHandler->Stop();
}

std::shared_ptr<SceneSim> FuncApp::GetSceneSim()
{
    return mSceneSim;
}

std::shared_ptr<RpcClient> FuncApp::GetRpc()
{
    return mRpcClient;
}

std::shared_ptr<FuncService> FuncApp::GetService()
{
    return mFuncService;
}

std::shared_ptr<FuncHandler> FuncApp::GetFuncHandler()
{
    return mFuncHandler;
}


}